package com.syf.feign1;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 整个包都是复制过来的：
 *      The bean 'authorization-server.FeignClientSpecification' could not be registered. A bean with that name has already been defined and overriding is disabled.
 *      解决@FeignClient(value = "服务名r") 设置可以有多个类存在相同的FeignClient 中的value值
 *
 *      1.设置beanName可以重复。不推荐，springboot2.x也不推荐这种做法，会覆盖已存在的bean
 *          spring.main.allow-bean-definition-overriding=true
 *      2.设置@FeignClient的contextId属性，推荐使用。
 *          @FeignClient(value = "trip-operation-core", contextId = "trip-operation-core-TenantClient")
 *          @FeignClient(value = "trip-operation-core", contextId = "trip-operation-core-tenant-temp-client")
 *          注意：
 *              contextId要尽量独一无二，不要和其他服务的client的contextId重复，推荐调用服务名+当前自己的服务名，例如：服务是trip-operation-core, 接口类名是TenantClient
 */
@FeignClient(value = "authorization-server") // contextId = "memberfeignsss"
public interface OAuth2FeignClient2 {
    @PostMapping("/oauth/token")  //2.指定 url路径
    ResponseEntity<JwtToken2> getToken2(
            @RequestParam("grant_type") String grantType, // 授权类型
            @RequestParam("username") String username, // 用户名
            @RequestParam("password") String password, // 用户的密码
            @RequestParam("login_type") String loginType,  // 登录的类型
            @RequestHeader("Authorization") String basicToken // Basic Y29pbi1hcGk6Y29pbi1zZWNyZXQ= 由第三方客户端信息加密出现的值
    );

}
